package com.cskaoyan.dbutils;

import com.cskaoyan.datasource.opensource.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ArrayHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * 创建日期: 2022/06/05 17:36
 *
 * @author ciggar
 *
 * ArrayHandler
 */
public class DBUtilsDemo5 {


    public static void main(String[] args) throws SQLException {

        // 创建一个QueryRunner ， 传入数据库连接池
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        Object[] objects = queryRunner.query("select id,teacher_name as teacherName,money,nickname from cskaoyan",
                new ArrayHandler());

        for (Object object : objects) {
            System.out.println(object);
        }

    }
}
